package pl.bizuteria.sklep.admin.client.activity.mapper;

import pl.bizuteria.sklep.admin.client.activity.bracelet.BraceletListActivity;
import pl.bizuteria.sklep.admin.client.activity.clip.ClipListActivity;
import pl.bizuteria.sklep.admin.client.activity.earing.EaringCreateActivity;
import pl.bizuteria.sklep.admin.client.activity.earing.EaringListActivity;
import pl.bizuteria.sklep.admin.client.place.ProxyCreatePlace;
import pl.bizuteria.sklep.admin.client.place.ProxyListPlace;
import pl.bizuteria.sklep.admin.client.ui.product.bracelet.BraceletEditView;
import pl.bizuteria.sklep.admin.client.ui.product.bracelet.BraceletProxyListView;
import pl.bizuteria.sklep.admin.client.ui.product.clip.ClipProxyListView;
import pl.bizuteria.sklep.admin.client.ui.product.earing.EaringEditView;
import pl.bizuteria.sklep.admin.client.ui.product.earing.EaringProxyListView;
import pl.bizuteria.sklep.api.shared.proxy.BraceletProxy;
import pl.bizuteria.sklep.api.shared.proxy.ClipProxy;
import pl.bizuteria.sklep.api.shared.proxy.EaringProxy;
import pl.bizuteria.sklep.api.shared.request.ApplicationRequestFactory;

import com.google.gwt.activity.shared.Activity;
import com.google.gwt.activity.shared.ActivityMapper;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.place.shared.Place;
import com.google.gwt.place.shared.PlaceController;
import com.google.inject.Inject;

public class ProductActivityMapper implements ActivityMapper {

	private EaringProxyListView earingView;
	EaringEditView earingEditView;
	private final PlaceController placeController;
	private final EventBus eventBus;
	BraceletProxyListView braceletView;
	private BraceletEditView braceletEditView;
	private final ApplicationRequestFactory requestFactory;
	private final ClipProxyListView clipView;

	@Inject
	public ProductActivityMapper(EventBus eventBus,
			EaringEditView earingEditView, EaringProxyListView earingView,
			PlaceController placeController,
			BraceletProxyListView braceletView,
			BraceletEditView braceletEditView,
			ApplicationRequestFactory requestFactory, ClipProxyListView clipView) {
		super();
		this.eventBus = eventBus;
		this.earingEditView = earingEditView;
		this.earingView = earingView;
		this.placeController = placeController;
		this.braceletView = braceletView;
		this.braceletEditView = braceletEditView;
		this.requestFactory = requestFactory;
		this.clipView = clipView;
	}

	public Activity getActivity(Place place) {
		if (place instanceof ProxyListPlace) {
			ProxyListPlace proxyListPlace = (ProxyListPlace) place;
			if (EaringProxy.class.equals(proxyListPlace.getProxyType())) {
				return new EaringListActivity(earingView, placeController,
						requestFactory);
			} else if (BraceletProxy.class
					.equals(proxyListPlace.getProxyType())) {
				return new BraceletListActivity(braceletView, placeController,
						requestFactory);
			} else if (ClipProxy.class.equals(proxyListPlace.getProxyType())) {
				return new ClipListActivity(clipView, placeController,
						requestFactory);
			}
			// } else if (place instanceof EaringCreatePlace) {
			// return new EaringCreateActivity(earingCreateView,
			// placeController);
			// } else if (place instanceof EaringEditPlace) {
			// return new EaringEditActivity(earingEditView,
			// ((EaringEditPlace) place).getStableId(), eventBus,
			// placeController, requestFactory);
			// } else if (place instanceof BraceletCreatePlace) {
			// return new BraceletCreateActivity(braceletCreateView,
			// placeController);

			// } else if (place instanceof BraceletEditPlace) {
			// return new BraceletEditActivity(braceletEditView,
			// ((BraceletEditPlace) place).getStableId(), eventBus,
			// placeController, requestFactory);
			// } else if (place instanceof ProxyEditPlace) {
			// ProxyEditPlace proxyEditPlace = (ProxyEditPlace) place;
			// if (EaringProxy.class.equals(proxyEditPlace.getStableId()
			// .getProxyClass())) {
			// return new EaringListActivity(earingView, placeController,
			// requestFactory);
			// } else if
			// (BraceletProxy.class.equals(proxyEditPlace.getStableId()
			// .getProxyClass())) {
			// return new BraceletListActivity(braceletView, placeController,
			// requestFactory);
			// }

			// return new EaringEditActivity(earingEditView,
			// ((EntityProxyId<EaringProxy>)proxyEditPlace.getStableId()),
			// eventBus,
			// placeController, requestFactory);
			// }
			// else if( place instanceof ProxyCreatePlace) {
			// ProxyCreatePlace proxyCreatePlace = (ProxyCreatePlace) place;
			// if (EaringProxy.class.equals(proxyCreatePlace.getProxyType())) {
			// return new EaringCreateActivity(earingCreateView,
			// placeController);
			// }
			// }
			
		}
		return null;
	}

}
